/************************************************************************
*                                                                       *
*       RTX-51 / CAN  DECLARATIONS FOR C-51 LANGUAGE                    *
*                                                                       *
* if this header file is included to a file using 82527 or C515C        *
* this file must be compiled with: define(EXTEND) preprocessor switch   *
*                                                                       *
*                                                                       *
************************************************************************/
/* Message-Structur for receive and send for 82527 and C515C */
#ifdef EXTEND
struct can_message_struct {
          unsigned long identifier;
          unsigned char c_data[8];
       };
/* Message-Structur for receive and send for all others CANs */
#else
struct can_message_struct {
          unsigned int identifier;
          unsigned char c_data[8];
       };
#endif


/* System functions returns */
#define C_OK                 0
#define C_NOT_STARTED        1
#define C_CONF_ERROR         2
#define C_OBJ_ERROR          3
#define C_TOO_LONG           4
#define C_INVALID_TYPE       5
#define C_MEM_FULL           6
#define C_NOT_STOPPED        7
#define C_OBJ_REBIND         8
#define C_TIMEOUT            9
#define C_CAN_FAILURE       10
#define C_ERR_ACTIVE        11
#define C_ERR_PASSIVE       12
#define C_BUS_OFF           13
#define C_SEND_ERROR        14

/* Object types for can_def_obj */
#define D_REC           0
#define D_SEND          1
#define D_REC_R_SEND    2
#define D_SEND_R_REC    3


/* System functions */
#pragma SAVE
#pragma REGPARMS


/* prototypes for all CANs  */
unsigned char can_task_create (void);

unsigned char can_hw_init (unsigned char par_1,
                           unsigned char par_2,
                           unsigned char par_3,
                           unsigned char par_4,
                           unsigned char par_5) large;

//the meanig of can_hw_init parameters are :
//       82527          C515C            81C92                  others          
//       -------------- ---------------- ---------------------- ------------
//par_1  bus_t0_reg     bit_timing_0_reg bit_length_1_reg       bus_timing_0
//par_2  bus_t1_reg     bit_timing_1_reg bit_length_2_reg       bus_timing_1
//par_3  bus_config_reg dummy            out_control_reg        out_control         
//par_4  cpu_interface  dummy            sleep_and_br_prescale  syncon      
//par_5  dummy          dummy            clock_control_reg      sleep_mode        



unsigned char can_def_obj (unsigned int identifier,
                            unsigned char data_length,
                            unsigned char object_typ);

/* prototype only for 82527 and C515C */
unsigned char can_def_obj_ext (unsigned long identifier,
                           unsigned char data_length,
                           unsigned char object_typ);

/* prototypes for all CANs  */
unsigned char can_stop (void);
unsigned char can_start (void);
unsigned char can_send (void xdata *msg_ptr);
unsigned char can_write (void xdata *msg_ptr);
unsigned char can_receive (unsigned char timeout,
                           void xdata *buffer_ptr);
unsigned char can_wait (unsigned char timeout,
                        void xdata *buffer_ptr);
unsigned char can_get_status (void);


/* prototypes for 82527 and C515C */
#ifdef EXTEND
unsigned char can_bind_obj (unsigned long identifier);
unsigned char can_unbind_obj (unsigned long identifier);
unsigned char can_request (unsigned long identifier);
unsigned char can_read (unsigned long identifier,
                            void xdata *buffer_ptr);

unsigned char can_def_last_obj (unsigned long last_msg_mask,
                                unsigned char data_length);
unsigned char can_def_last_obj_ext (unsigned long last_msg_mask,
                                    unsigned char data_length);
unsigned char can_read_last_obj (void xdata *buffer_ptr);
unsigned char can_bind_last_obj (void);
unsigned char can_unbind_last_obj (void);

/* prototypes for all other CANs */
#else
unsigned char can_bind_obj (unsigned int identifier);
unsigned char can_unbind_obj (unsigned int identifier);
unsigned char can_request (unsigned int identifier);
unsigned char can_read (unsigned int identifier,
                        void xdata *buffer_ptr);
#endif

#pragma RESTORE
/* End of include */




